<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="就诊人列表" name="first">
				<div style="display: flex;justify-content: space-between;align-items: center">
					<div>
						<!-- <div style="position: relative;display: inline-block;margin: 3px;">
							<span>就诊人名称：</span>
							<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入就诊人名称"
								v-model="realNameT"></el-input>&nbsp;&nbsp;
						</div> -->
						<div style="position: relative;display: inline-block;margin: 3px;">
							<span>所属用户昵称：</span>
							<el-input style="width: 200px;" @keydown.enter.native="select"
									  placeholder="请输入所属用户昵称"
									  v-model="userName"></el-input>&nbsp;&nbsp;
						</div>
						<div style="position: relative;display: inline-block;margin: 3px;">
							<span>就诊人电话：</span>
							<el-input style="width: 200px;" @keydown.enter.native="select"
									  placeholder="请输入就诊人电话"
									  v-model="phone"></el-input>&nbsp;&nbsp;
						</div>
						<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="select">
							查询
						</el-button>
						<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans">
							重置
						</el-button>
						<el-button v-if="!shopId" style='margin: 10px 0;' :disabled="!isAuth('carBrandList:add')"
								   size="mini"
								   type="primary" icon="document" @click="addPatient()">添加就诊人
						</el-button>
					</div>
				</div>
				<el-table v-loading="tableDataLoading" :data="tableData.records">
					<el-table-column fixed prop="patientId" label="编号" width="80">
					</el-table-column>
					<el-table-column prop="userName" label="所属用户昵称">
						<template slot-scope="scope">
							<!-- <span style="color: #009900;cursor: pointer;"
								@click="updates(scope.row.userId)">{{ scope.row.userName }}</span> -->
							<el-button size="mini" style="color: #008000;background: #fff;border: none;padding: 0;"
									   type="primary"
									   :disabled="!isAuth('userList:details')" @click="updates(scope.row.userId)">
								{{ scope.row.userName ? scope.row.userName : '未绑定' }}
							</el-button>
						</template>
					</el-table-column>
					<el-table-column prop="userName" label="就诊人名称">
						<template slot-scope="scope">
							<span>{{ scope.row.realName }}</span>
						</template>
					</el-table-column>
					<el-table-column prop="userName" label="性别">
						<template slot-scope="scope">
							<span>{{ scope.row.sex == 1 ? '男' : '女' }}</span>
						</template>
					</el-table-column>
					<el-table-column prop="isUnderAge" label="是否满18岁">
						<template slot-scope="scope">
							<span>{{ scope.row.isUnderAge == 1 ? '是' : '否' }}</span>
						</template>
					</el-table-column>
					<el-table-column prop="relationship" label="与就诊人关系">
					</el-table-column>
					<el-table-column prop="phone" label="就诊人电话">
					</el-table-column>
					<el-table-column prop="idNumber" label="身份证号码">
					</el-table-column>
					<el-table-column prop="emergencyPhone" label="紧急联系人电话">
					</el-table-column>

					<el-table-column label="操作" width="205">
						<template slot-scope="scope">
							<el-button size="mini" type="primary"
									   @click="fuWuHistory(scope.row.patientId)" style="margin: 5px;">服务历史
							</el-button>
							<el-button size="mini" type="primary"
									   @click="fuWuPingJia(scope.row.userId)" style="margin: 5px;">服务评价
							</el-button>
							<el-button v-if="!shopId" size="mini" type="primary"
									   :disabled="!isAuth('carBrandList:update')"
									   @click="addPatient(scope.row)" style="margin: 5px;">修改
							</el-button>
							<el-button v-if="!shopId" size="mini" type="danger"
									   :disabled="!isAuth('carBrandList:delete')"
									   @click="deletes(scope.row)" style="margin: 5px;">删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;">
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
								   :page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page"
								   layout="total,sizes, prev, pager, next,jumper" :total="tableData.total">
					</el-pagination>
				</div>
			</el-tab-pane>
		</el-tabs>
		<!--添加就诊人-->
		<el-dialog :title="titles" :visible.sync="dialogVisible" width="60%" center>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">所属用户：</span>
				<el-input v-model="numberValidateForm.userName" @focus="userBtn()" style="width:45%;"
						  placeholder="请输入所属用户">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">姓名：</span>
				<el-input v-model="numberValidateForm.realName" style="width:45%;" placeholder="请输入姓名">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">性别：</span>
				<el-radio-group v-model="numberValidateForm.sex">
					<el-radio :label="1">男</el-radio>
					<el-radio :label="2">女</el-radio>
				</el-radio-group>
			</div>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">是否满18岁：</span>
				<el-radio-group v-model="numberValidateForm.isUnderAge">
					<el-radio :label="1">是</el-radio>
					<el-radio :label="0">否</el-radio>
				</el-radio-group>
			</div>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">身份证号码：</span>
				<el-input v-model="numberValidateForm.idNumber" style="width:45%;" placeholder="请输入身份证号码">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">电话号码：</span>
				<el-input v-model="numberValidateForm.phone" style="width:45%;" placeholder="请输入电话号码">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">紧急联系人电话：</span>
				<el-input v-model="numberValidateForm.emergencyPhone" style="width:45%;"
						  placeholder="请输入紧急联系人电话">
				</el-input>
			</div>

			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">就诊人关系：</span>
				<el-select style="width: 45%" v-model="numberValidateForm.relationship" placeholder="请选择就诊人关系">
					<el-option v-for="(item,index) in gxList" :key="index" :label="item.value" :value="item.value">
					</el-option>
				</el-select>
			</div>
			<span slot="footer" class="dialog-footer" style="margin-top: 30px;text-align: center;">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="addNoticeTo()">确 定</el-button>
			</span>
		</el-dialog>
		<!--选择用户-->
		<el-dialog title="选择用户" :visible.sync="dialogVisibles" width="70%" center>
			<div style="margin:2% 0;display: inline-block;">
				<span>手机号:</span>
				<el-input style="width: 150px;" @keydown.enter.native="selectUser" clearable placeholder="请输入手机号"
						  v-model="phoneUser"></el-input>
			</div>&emsp;&emsp;
			<div style="margin:2% 0;display: inline-block;">
				<span>昵称:</span>
				<el-input style="width: 150px;" @keydown.enter.native="selectUser" clearable placeholder="请输入昵称"
						  v-model="userNameUser"></el-input>
			</div>&emsp;&emsp;
			<div style="display: inline-block;">
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="selectUser">查询
				</el-button>
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleansUser">重置
				</el-button>
			</div>
			<el-table v-loading="tableDataLoadings" :data="userList.list">
				<el-table-column fixed prop="userId" label="编号" width="80">
				</el-table-column>
				<el-table-column fixed prop="userName" label="昵称" width="150">
					<template slot-scope="scope">
						<span style="color: #f56c6c;">{{ scope.row.userName ? scope.row.userName : '未绑定' }}</span>
					</template>
				</el-table-column>
				<el-table-column prop="sex" label="性别">
					<template slot-scope="scope">
						<span v-if="scope.row.sex==1">男</span>
						<span v-else-if="scope.row.sex==2">女</span>
						<span v-else>未设置</span>
					</template>
				</el-table-column>
				<el-table-column label="图像">
					<template slot-scope="scope">
						<img v-if="scope.row.avatar==null" src="~@/assets/img/avatar.png" alt="" width="40" height="40">
						<img v-else :src="scope.row.avatar" alt="" width="40" height="40">
					</template>
				</el-table-column>
				<el-table-column prop="phone" label="手机号">
					<template slot-scope="scope">
						<!-- <span style="color: #4f9dec;cursor: pointer;" @click="updates(scope.row)">
							{{ scope.row.phone ? scope.row.phone : '未绑定' }}
						</span> -->
						<el-button size="mini" style="color: #008000;background: #fff;border: none;padding: 0;"
								   type="primary"
								   :disabled="!isAuth('userList:details')" @click="updates(scope.row.userId)">
							{{ scope.row.phone ? scope.row.phone : '未绑定' }}
						</el-button>
					</template>
				</el-table-column>
				<el-table-column prop="invitationCode" label="邀请码"></el-table-column>
				<el-table-column label="邀请人邀请码">
					<template slot-scope="scope">
						<span style="color: #4f9dec;cursor: pointer;"
							  @click="updates2(scope.row)">{{
								scope.row.inviterCode ? scope.row.inviterCode : '未绑定'
							}}</span>
					</template>
				</el-table-column>
				<el-table-column label="操作" width="80">
					<template slot-scope="scope">
						<el-button size="mini" type="primary" :disabled="!isAuth('carBrandList:update')"
								   @click="amendBanner(scope.row)" style="margin: 5px;">选择
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div style="text-align: center;margin-top: 10px;">
				<el-pagination @size-change="handleSizeChanges" @current-change="handleCurrentChanges"
							   :page-sizes="[10, 20, 30, 40]" :page-size="limit1" :current-page="page1"
							   layout="total,sizes, prev, pager, next,jumper" :total="userList.totalCount">
				</el-pagination>
			</div>
		</el-dialog>
		<!--服务历史-->
		<el-dialog title="服务历史" :visible.sync="dialogVisibleFW" width="70%" center>
			<div style="display: inline-block;">
				<div style="position: relative;display: inline-block;margin: 3px;">
					<span>订单类型：</span>
					<el-select v-model="type" style="width:150px;margin-left: 10px;" @change="animeDat(type)">
						<el-option v-for="item in typeNum" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</div>
				<div style="position: relative;display: inline-block;margin: 3px;">
					<span>医院：</span>
					<el-select v-model="hospitalId" filterable style="width:150px;margin-left: 10px;"
							   @change="animeDat(hospitalId)">
						<el-option v-for="item in hospitalList" :key="item.hospitalId" :label="item.hospitalName"
								   :value="item.hospitalId">
						</el-option>
					</el-select>&nbsp;&nbsp;&nbsp;
				</div>
				<div style="position: relative;display: inline-block;margin: 3px;">
					<span>下单用户：</span>
					<el-input style="width: 200px;" @keydown.enter.native="selectFuWu" placeholder="请输入下单用户"
							  v-model="userNameX"></el-input>&nbsp;&nbsp;
				</div>
				<div style="position: relative;display: inline-block;margin: 3px;">
					<span>接单用户：</span>
					<el-input style="width: 200px;" @keydown.enter.native="selectFuWu" placeholder="请输入接单用户"
							  v-model="userNameJ"></el-input>&nbsp;&nbsp;
				</div>
				<div style="position: relative;display: inline-block;margin: 3px;">
					<span>订单编号：</span>
					<el-input style="width: 200px;" @keydown.enter.native="selectFuWu" placeholder="请输入订单编号"
							  v-model="ordersNo"></el-input>&nbsp;&nbsp;
				</div>
				<div style="margin:5px;display: inline-block;">
					<span>开始时间：</span>
					<el-date-picker style="width: 160px;margin-left: 10px;" v-model="startTime" align="right"
									type="datetime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择开始时间">
					</el-date-picker>&nbsp;&nbsp;&nbsp;
				</div>
				<div style="margin:5px;display: inline-block;">
					<span>截止时间：</span>
					<el-date-picker style="width: 160px;margin-left: 10px;" v-model="endTime" align="right"
									type="datetime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择截止时间">
					</el-date-picker>
				</div>
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="selectFuWu">查询
				</el-button>
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleanFuWu">重置
				</el-button>
			</div>
			<el-table v-loading="tableDataLoading" :data="fuWuData.records" height="50vh">
				<el-table-column prop="ordersId" label="编号" width="80" fixed="left">
				</el-table-column>

				<el-table-column prop="userName" label="下单用户">
					<template slot-scope="scope"> <!--  -->
						<el-button size="mini" style="color: #008000;background: #fff;border: none;padding: 0;" type="primary"
								   :disabled="!isAuth('userList:details')" @click="updates(scope.row.userId)">
							{{scope.row.ordersUserName ? scope.row.ordersUserName : '未绑定'}}
						</el-button>
						<!-- <span style="color: #008000;cursor: pointer;" @click="updates(scope.row.userId)"
							v-if="scope.row.ordersType==1">{{ scope.row.ordersUserName }}</span>
						<span style="color: #008000;cursor: pointer;" @click="updates(scope.row.userId)"
							v-if="scope.row.ordersType==2">{{ scope.row.ordersUserName }}</span> -->
					</template>
				</el-table-column>
				<el-table-column prop="userName" label="接单用户">
					<template slot-scope="scope">
						<span v-if="scope.row.state==0"> - </span>
						<span v-else style="color: #009900;cursor: pointer;" @click="updates(scope.row.orderTakingUserId)" >{{ scope.row.userName?scope.row.userName:'未绑定' }}</span>
					</template>
				</el-table-column>
				<el-table-column prop="ordersNo" label="订单编号" width="150">
				</el-table-column>
				<el-table-column prop="ordersType" label="订单类型">
					<template slot-scope="scope">
						<span v-if="scope.row.ordersType==1">陪诊订单</span>
						<span v-if="scope.row.ordersType==2">陪护订单</span>
					</template>
				</el-table-column>
				<el-table-column prop="appointInformation.hospitalName" label="医院名称" width="150">
				</el-table-column>
				<el-table-column prop="hospitalImg" label="医院照片" width="200">
					<template slot-scope="scope">
						<div v-if="scope.row.appointInformation&&scope.row.appointInformation.hospitalImg">
							<img v-for="(item,index) in scope.row.appointInformation.hospitalImg.split(',')"
								 :key="index" :src="item" width="40" height="40" style="margin:3px" />
						</div>
					</template>
				</el-table-column>

				<el-table-column prop="appointInformation.departmentName" label="科室" width="150">
				</el-table-column>
				<el-table-column prop="appointInformation.type" label="服务类型">
					<template slot-scope="scope">
						<span v-if="scope.row.appointInformation&&scope.row.appointInformation.type==1">陪诊</span>
						<span v-if="scope.row.appointInformation&&scope.row.appointInformation.type==2">陪护</span>
						<span v-if="scope.row.appointInformation&&scope.row.appointInformation.type==3">助浴</span>
						<span v-if="scope.row.appointInformation&&scope.row.appointInformation.type==4">护理</span>
					</template>
				</el-table-column>
				<el-table-column prop="appointInformation.serviceName" label="服务名称">
				</el-table-column>
				<el-table-column prop="appointInformation.tags" label="服务标签" width="160">
				</el-table-column>
				<el-table-column prop="img" label="服务照片" width="200">
					<template slot-scope="scope">
						<div v-if="scope.row.appointInformation&&scope.row.appointInformation.img">
							<img v-for="(item,index) in scope.row.appointInformation.img.split(',')" :key="index"
								 :src="item" width="40" height="40" style="margin:3px" />
						</div>
					</template>
				</el-table-column>
				<el-table-column prop="appointInformation.patientInfo.realName" label="预约人姓名" width="150">
					<template slot-scope="scope">
						<span v-if="scope.row.appointInformation&&scope.row.appointInformation.patientInfo">
							<span v-if="scope.row.appointInformation.patientInfo">
								{{scope.row.appointInformation.patientInfo.realName}}
							</span>

						</span>
						<!-- <span style="cursor: pointer;color: #4f9dec;" @click="dataDel(scope.row,4)">查看详情</span> -->
					</template>
				</el-table-column>

				<el-table-column prop="appointInformation.patientInfo.emergencyPhone" label="紧急联系人电话" width="160">
				</el-table-column>
				<el-table-column prop="couponMoney" label="优惠券金额" width="120">
					<template slot-scope="scope">
						<span>{{scope.row.couponMoney?scope.row.couponMoney:'0'}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="sfZhiRate" label="上级师傅佣金" width="120">
					<template slot-scope="scope">
						<!-- <span style="color: #DD0000;cursor: pointer;"
							@click="updates(scope.row.sfZhiUserId)">{{scope.row.sfZhiRate?scope.row.sfZhiRate:'0'}}</span> -->
						<el-button size="mini" style="color: #DD0000;background: #fff;border: none;padding: 0;" type="primary"
								   :disabled="!isAuth('userList:details')" @click="updates(scope.row.sfZhiUserId)">
							{{scope.row.sfZhiRate ? scope.row.sfZhiRate : '0'}}
						</el-button>
					</template>
				</el-table-column>
				<el-table-column prop="rate" label="陪诊/陪护佣金" width="120">
					<template slot-scope="scope">
						<span>{{scope.row.rate?scope.row.rate:'0'}}</span>
					</template>
				</el-table-column>

				<el-table-column prop="zhiRate" label="推广员佣金" width="120">
					<template slot-scope="scope">
						<!-- <span style="color: #DD0000;cursor: pointer;"
							@click="updates(scope.row.zhiUserId)">{{scope.row.zhiRate?scope.row.zhiRate:'0'}}</span> -->
						<el-button size="mini" style="color: #DD0000;background: #fff;border: none;padding: 0;" type="primary"
								   :disabled="!isAuth('userList:details')" @click="updates(scope.row.zhiUserId)">
							{{scope.row.zhiRate ? scope.row.zhiRate : '0'}}
						</el-button>
					</template>
				</el-table-column>
				<el-table-column prop="feiRate" label="代理商佣金" width="120">
					<template slot-scope="scope">
						<!-- <span style="color: #DD0000;cursor: pointer;"
							@click="updates(scope.row.feiUserId)">{{scope.row.feiRate?scope.row.feiRate:'0'}}</span> -->
						<el-button size="mini" style="color: #DD0000;background: #fff;border: none;padding: 0;" type="primary"
								   :disabled="!isAuth('userList:details')" @click="updates(scope.row.feiUserId)">
							{{scope.row.feiRate ? scope.row.feiRate : '0'}}
						</el-button>
					</template>
				</el-table-column>
				<el-table-column prop="pingRate" label="平台金额">
					<template slot-scope="scope">
						<span>{{scope.row.pingRate?scope.row.pingRate:'0'}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="payMoney" label="支付金额">
					<template slot-scope="scope">
						<span style="color: #f56c6c;">{{scope.row.payMoney}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="appointInformation.hopeTime" label="预约时间" width="160">
					<template slot-scope="scope">
						<span v-if="scope.row.appointInformation">{{scope.row.appointInformation.hopeTime}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="appointInformation.remarks" label="备注" width="200">
					<template slot-scope="scope">
						<span v-if="scope.row.appointInformation">{{scope.row.appointInformation.remarks}}</span>
					</template>
				</el-table-column>
				<!-- <el-table-column prop="orderImg" label="图片" width="200">
					<template slot-scope="scope">
						<div v-if="scope.row.orderImg">
							<div v-for="(item,index) in scope.row.orderImg.split(',')" :key="index">
								<el-popover placement="top-start" title="" trigger="hover">
									<img  :src="item" width="40" height="40" style="margin:3px" slot="reference" />
									<img  :src="item" width="200" height="200" style="margin:3px" />

								</el-popover>
							</div>
						</div>
					</template>
				</el-table-column> -->
				<el-table-column prop="imgRemarks" label="图片备注" width="200">
					<template slot-scope="scope">
						<div v-if="scope.row.appointInformation&&scope.row.appointInformation.imgRemarks">
							<div v-for="(item,index) in scope.row.appointInformation.imgRemarks.split(',')" :key="index"
								 style="display: inline-block;margin: 3ox;">
								<el-popover placement="top-start" title="" trigger="hover">
									<img :src="item" width="40" height="40" style="margin:3px" slot="reference" />
									<img :src="item" width="200" height="200" style="margin:3px" />

								</el-popover>
							</div>
						</div>
					</template>
				</el-table-column>
				<el-table-column prop="code" label="确认码">
				</el-table-column>
				<el-table-column prop="isTransfer" label="是否是转单" fixed="right" width="100">
					<template slot-scope="scope">
						<span style="color: #999;" v-if="scope.row.isTransfer==1">是</span>
						<span style="color: #999;" v-else>否</span>
					</template>
				</el-table-column>
				<el-table-column prop="state" label="订单状态" fixed="right">
					<template slot-scope="scope">
						<span style="color: #f56c6c;" v-if="scope.row.state==0">待支付</span>
						<span style="color: #E87D0D;" v-if="scope.row.state==1">进行中</span>
						<span style="color: #E87D0D;" v-if="scope.row.state==5">待服务</span>
						<span style="color: #009900;" v-if="scope.row.state==2">已完成</span>
						<span style="color: #999;" v-if="scope.row.state==3">已取消</span>
						<span style="color: #999;" v-if="scope.row.state==4">待接单</span>
					</template>
				</el-table-column>
				<el-table-column prop="createTime" label="创建时间" width="160">
				</el-table-column>
			</el-table>
			<div style="text-align: center;margin-top: 10px;">
				<el-pagination @size-change="handleSizeChangeFuWu" @current-change="handleCurrentChangeFuWu"
							   :page-sizes="[10, 20, 30, 40]" :page-size="limit2" :current-page="page2"
							   layout="total,sizes, prev, pager, next,jumper" :total="fuWuData.total">
				</el-pagination>
			</div>
		</el-dialog>
		<!--服务评价-->
		<el-dialog title="服务评价" :visible.sync="dialogVisiblePJ" width="70%" center>
			<div style="margin:6px 0;display: inline-block;">
				<span>被评用户：</span>
				<el-input style="width: 150px;" @keydown.enter.native="selectPJ" clearable placeholder="请输入被评用户"
						  v-model="riderUserName"></el-input>&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
			<div style="margin:6px 0;display: inline-block;">
				<span>订单号：</span>
				<el-input style="width: 150px;" @keydown.enter.native="selectPJ" clearable placeholder="请输入订单号"
						  v-model="orderNoPJ"></el-input>&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
			<div style="margin:6px 0;display: inline-block;">
				<span>评论内容/关键字：</span>
				<el-input style="width: 200px;" @keydown.enter.native="selectPJ" clearable placeholder="请输入评论内容/关键字"
						  v-model="content"></el-input>&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
			<div style="display: inline-block;">
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="selectPJ">查询
				</el-button>
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleanPJ">重置
				</el-button>
			</div>
			<el-table v-loading="tableDataLoading" :data="fuWuPJData.records">
				<el-table-column prop="evaluateId" label="编号" width="80">
				</el-table-column>
				<el-table-column prop="userName" label="评论用户" width="150">
					<template slot-scope="scope">
						<el-button size="mini" style="color: #008000;background: #fff;border: none;padding: 0;" type="primary"
								   :disabled="!isAuth('userList:details')" @click="updates(scope.row.userId)">
							{{scope.row.userName ? scope.row.userName : '未绑定'}}
						</el-button>
					</template>
				</el-table-column>
				<el-table-column prop="rideName" label="被评用户" width="150">
					<template slot-scope="scope">
						<el-button size="mini" :disabled="!isAuth('userList:details')"  style="color: #4f9dec;background: #fff;border: none;padding: 0;" type="primary" @click="updates(scope.row.riderUserId)">
							{{ scope.row.rideName ? scope.row.rideName : '未绑定' }}
						</el-button>
					</template>
				</el-table-column>
				<el-table-column prop="indentNumber" label="订单号">
				</el-table-column>
				<el-table-column prop="evaluateMessage" label="信息内容">
				</el-table-column>
				<el-table-column prop="evaluateImg" label="评论图片">
					<template slot-scope="scope">
						<div v-if="scope.row.evaluateImg">
								<span v-for="(item, index) in scope.row.evaluateImg.split(',')" :key="index">
									<el-popover placement="top-start" title="" trigger="hover">
										<img style="width: 50px; height: 50px;margin: 3px;" :src="item" alt=""
											 slot="reference">
										<img style="width: 200px; height: 200px" :src="item" alt="">
									</el-popover>
								</span>
						</div>
					</template>
				</el-table-column>
				<el-table-column prop="satisfactionFlag" label="评分" width="80">
				</el-table-column>
				<el-table-column prop="shopReplyMessage" label="回复内容" width="180">
				</el-table-column>
				<el-table-column prop="createTime" label="创建时间" width="150">
				</el-table-column>
			</el-table>
			<div style="text-align: center;margin-top: 10px;">
				<el-pagination @size-change="handleSizeChangePJ" @current-change="handleCurrentChangePJ"
							   :page-sizes="[10, 20, 30, 50, 100]" :page-size="limit3" :current-page="page3"
							   layout="total,sizes, prev, pager, next" :total="fuWuPJData.total">
				</el-pagination>
			</div>
		</el-dialog>
	</div>
</template>

<script>
export default {
	data () {
		return {
			userList: {},
			gxList: [],
			page: 1,
			limit: 10,
			page1: 1,
			limit1: 10,
			page2: 1,
			limit2: 10,
			page3: 1,
			limit3: 10,
			tableData: {},
			fuWuData: {},
			fuWuPJData: {},
			memberName: '',
			memberImg: '',
			memberId: '',
			activeName: 'first',
			phone: '',
			userName: '',
			userNameX: '',
			userNameJ: '',
			tableDataLoading: false,
			tableDataLoadings: false,
			dialogVisible: false,
			dialogVisibles: false,
			dialogVisibleFW: false,
			dialogVisiblePJ: false,
			title: '添加就诊人',
			numberValidateForm: {
				realName: '',
				sex: 1,
				isUnderAge: 1,
				idNumber: '',
				relationship: '',
				userName: '',
				userId: '',
				phone: '',
				emergencyPhone: '',
			},
			titles: '添加就诊人',
			phoneUser: '',
			userNameUser: '',
			realNameT: '',
			shopId: sessionStorage.getItem('shopId') || null,
			patientId: undefined,
			typeNum: [{
				value: '',
				label: '全部'
			},
				{
					value: 1,
					label: '陪诊订单'
				},
				{
					value: 2,
					label: '陪护订单'
				},
			],
			type: undefined,
			hospitalList: [],
			hospitalId:undefined,
			ordersNo:undefined,
			startTime:undefined,
			endTime:undefined,
			userId:undefined,
			riderUserName:undefined,
			orderNoPJ:undefined,
			content:undefined
		}
	},
	methods: {
		fuWuHistory (patientId) {
			this.patientId = patientId
			this.dialogVisibleFW = true
			this.$http({
				url: this.$http.adornUrl('/orders/queryOrders'),
				method: 'get',
				params: this.$http.adornParams({
					'page': this.page2,
					'limit': this.limit2,
					'type': this.type,
					'name': this.userNameJ,
					'userName': this.userNameX,
					'status': 2,
					'userId': this.userId,
					'ordersNo': this.ordersNo,
					'startTime': this.startTime,
					'endTime': this.endTime,
					'hospitalId': this.hospitalId,
					'shopId': null,
					'patientId': this.patientId
				})
			}).then(({
				data
			}) => {
				if (data && data.code === 0) {
					this.fuWuData = data.data
				}

			})
		},
		fuWuPingJia(userId){
			this.userId = userId
			this.dialogVisiblePJ = true
			this.$http({
				url: this.$http.adornUrl('admin/evaluate/getUserEvaluate'),
				method: 'get',
				params: this.$http.adornParams({
					'page': this.page3,
					'limit': this.limit3,
					'userId': this.userId,
					'rideName': this.riderUserName,
					'evaluateMessage': this.content,
					'indentNumber': this.orderNoPJ,
				})
			}).then(({
				data
			}) => {
				let returnData = data.data;
				this.fuWuPJData = returnData
			})
		},
		cleanPJ(){
			this.page3 = 1
			this.riderUserName = ''
			this.content = ''
			this.orderNoPJ = ''
			this.fuWuPingJia()
		},
		// 医院列表
		dataSelectHospitalList() {
			this.$http({
				url: this.$http.adornUrl('admin/hospital/getHospitalList'),
				method: 'get',
				params: this.$http.adornParams({

				})
			}).then(({
				data
			}) => {
				if(data.data){
					this.hospitalList = data.data.records
				}else{
					this.hospitalList = []
				}
			})
		},
		handleClick (tab, event) {
			if (tab._props.label == '就诊人列表') {
				this.dataSelect()
			}
		},
		//获取用户列表
		getUserList () {
			this.tableDataLoadings = true
			this.$http({
				url: this.$http.adornUrl('user/selectUserList'),
				method: 'get',
				params: this.$http.adornParams({
					'page': this.page1,
					'limit': this.limit1,
					'isPromotion': -1,
					'phone': this.phoneUser,
					'userName': this.userNameUser,
					'isAuthentication': 2,
					'isAgent': -1
				})
			}).then(({
				data
			}) => {
				if (data && data.code === 0) {
					this.tableDataLoadings = false
					let returnData = data.data
					this.userList = returnData
				}

			})
		},
		selectUser () {
			this.page1 = 1
			this.getUserList()
		},
		cleansUser () {
			this.page1 = 1
			this.phoneUser = ''
			this.userNameUser = ''
			this.getUserList()
		},
		// 用户列表弹框
		userBtn () {
			this.dialogVisibles = true
			this.getUserList()
		},

		//获取就诊关系
		getgxList () {
			let data = {
				type: '就诊人关系'
			}
			this.$http({
				url: this.$http.adornUrl('sys/dict/selectDictList'),
				method: 'get',
				params: this.$http.adornParams(data)
			}).then(({
				data
			}) => {
				if (data && data.code === 0) {
					this.gxList = data.data
				}

			})
		},
		// 获取数据列表
		dataSelect () {
			this.tableDataLoading = true
			this.$http({
				url: this.$http.adornUrl('admin/patientInfo/getPatientList'),
				method: 'get',
				params: this.$http.adornParams({
					'page': this.page,
					'limit': this.limit,
					'realName': this.realNameT,
					'phone': this.phone,
					'userName': this.userName
				})
			}).then(({
				data
			}) => {
				if (data && data.code === 0) {
					this.tableDataLoading = false
					let returnData = data.data
					this.tableData = returnData
				}

			})
		},
		select () {
			this.page = 1
			this.dataSelect()
		},
		selectFuWu(){
			this.page2 = 1
			this.fuWuHistory(this.patientId)
		},
		selectPJ(){
			this.page3 = 1
			this.fuWuPingJia(this.userId)
		},
		cleans () {
			this.page = 1
			this.userName = ''
			this.phone = ''
			this.realNameT = ''
			this.dataSelect()
		},
		cleanFuWu () {
			this.page2 = 1
			this.userNameX = ''
			this.userNameJ = ''
			this.type = ''
			this.hospitalId = ''
			this.ordersNo = ''
			this.startTime = ''
			this.endTime = ''
			this.fuWuHistory(this.patientId)
		},
		handleCurrentChange (val) {
			this.page = val
			this.dataSelect()
		},
		handleSizeChange (val) {
			this.limit = val
			this.dataSelect()
		},
		handleCurrentChanges (val) {
			this.page1 = val
			this.getUserList()
		},
		handleSizeChanges (val) {
			this.limit1 = val
			this.getUserList()
		},
		handleSizeChangeFuWu (val) {
			this.limit2 = val
			this.fuWuHistory(this.patientId)
		},
		handleSizeChangePJ (val) {
			this.limit3 = val
			this.fuWuPingJia(this.userId)
		},
		handleCurrentChangeFuWu (val) {
			this.page2 = val
			this.fuWuHistory(this.patientId)
		},
		handleCurrentChangePJ (val) {
			this.page3 = val
			this.fuWuPingJia(this.userId)
		},
		// 添加、修改就诊人弹框
		addPatient (row) {
			if (row) {
				this.titles = '修改就诊人'
				this.numberValidateForm.userId = row.userId
				this.numberValidateForm.isUnderAge = row.isUnderAge
				this.numberValidateForm.sex = row.sex
				this.numberValidateForm.realName = row.realName
				this.numberValidateForm.phone = row.phone
				this.numberValidateForm.idNumber = row.idNumber
				if (row.emergencyPhone) {
					this.numberValidateForm.emergencyPhone = row.emergencyPhone
				} else {
					this.numberValidateForm.emergencyPhone = ''
				}

				this.numberValidateForm.relationship = row.relationship
				this.numberValidateForm.patientId = row.patientId
				this.numberValidateForm.userName = row.userName
			} else {
				this.titles = '添加就诊人'
				this.numberValidateForm.userId = ''
				this.numberValidateForm.isUnderAge = 1
				this.numberValidateForm.sex = 1
				this.numberValidateForm.realName = ''
				this.numberValidateForm.phone = ''
				this.numberValidateForm.idNumber = ''
				this.numberValidateForm.relationship = ''
				this.numberValidateForm.patientId = ''
				this.numberValidateForm.userName = ''
				this.numberValidateForm.emergencyPhone = ''
			}
			this.dialogVisible = true
		},
		// 添加/修改就诊人
		addNoticeTo () {
			if (this.numberValidateForm.userId == '') {
				this.$notify({
					title: '提示',
					duration: 1800,
					message: '请选择所属用户',
					type: 'warning'
				})
				return
			}
			if (this.numberValidateForm.realName == '') {
				this.$notify({
					title: '提示',
					duration: 1800,
					message: '请输入姓名',
					type: 'warning'
				})
				return
			}
			if (this.numberValidateForm.idNumber == '') {
				this.$notify({
					title: '提示',
					duration: 1800,
					message: '请输入身份证号码',
					type: 'warning'
				})
				return
			}
			if (this.numberValidateForm.phone == '') {
				this.$notify({
					title: '提示',
					duration: 1800,
					message: '请输入手机号',
					type: 'warning'
				})
				return
			}
			// if (this.numberValidateForm.emergencyPhone == '') {
			// 	this.$notify({
			// 		title: '提示',
			// 		duration: 1800,
			// 		message: '请输入紧急联系人电话',
			// 		type: 'warning'
			// 	});
			// 	return
			// }
			if (this.numberValidateForm.relationship == '') {
				this.$notify({
					title: '提示',
					duration: 1800,
					message: '请选择就诊人关系',
					type: 'warning'
				})
				return
			}
			this.$http({
				url: this.$http.adornUrl('admin/patientInfo/savePatient'),
				method: 'post',
				// data: this.$http.adornData({
				params: this.$http.adornParams({
					'userId': this.numberValidateForm.userId,
					'isUnderAge': this.numberValidateForm.isUnderAge,
					'sex': this.numberValidateForm.sex,
					'realName': this.numberValidateForm.realName,
					'phone': this.numberValidateForm.phone,
					'idNumber': this.numberValidateForm.idNumber,
					'relationship': this.numberValidateForm.relationship,
					'patientId': this.numberValidateForm.patientId,
					'emergencyPhone': this.numberValidateForm.emergencyPhone,

				})
			}).then(({
				data
			}) => {
				if (data.code == 0) {
					this.dialogVisible = false
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.dataSelect()
						}
					})
				} else {
					this.$message({
						message: data.msg,
						type: 'warning',
						duration: 1500,
						onClose: () => {
						}
					})
				}

			})
		},
		// 选择用户
		amendBanner (row) {
			this.numberValidateForm.userName = row.userName
			this.numberValidateForm.userId = row.userId
			this.dialogVisibles = false
		},
		//删除
		deletes (row) {
			this.$confirm(`确定删除此条信息?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				let data = {
					userId: row.userId,
					patientId: row.patientId
				}
				this.$http({
					url: this.$http.adornUrl('admin/patientInfo/deletePatient'),
					method: 'get',
					params: this.$http.adornParams(data)
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.$message({
							message: '删除成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.dataSelect()
							}
						})
					} else {
						this.$message({
							message: data.msg,
							type: 'warning',
							duration: 1500,
							onClose: () => {
							}
						})
					}

				})
			}).catch(() => {
			})
		},
		// 详情跳转
		updates (userId) {
			if (userId) {
				this.$router.push({
					path: '/userDetail',
					query: {
						userId: userId
					}
				})
			}

		},
		// select选择事件
		animeDat(state) {
			this.page2 = 1
			this.fuWuHistory(this.patientId)
		},
	},
	mounted () {
		this.dataSelect()
		this.getgxList()
		this.dataSelectHospitalList()
	}
}
</script>

<style>
</style>
